package com.ivo.sys;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.ivo.util.JsonUtil;

/**
 * 
 *
 * @author Minkey Wang
 * @version 2017年7月8日
 */
@RestController
@RequestMapping("/sys/code")
public class CodeController {
	@Autowired
	private CodeService codeService;
	
    @RequestMapping(value = "/list")
    @ResponseBody
    public String list(HttpServletRequest request) {
    	List<Code> list = codeService.list(); 
    	Map<String, Object> returnMap = new HashMap<String, Object>(); 
    	if(list.size()>0){
        	returnMap.put("err_code", "0");
            returnMap.put("err_msg", "success");
            returnMap.put("result", list);
    	}
//    	String s = JsonUtil.toJson(returnMap);
    	return JsonUtil.toJson(returnMap);
    	
    }
    
    @RequestMapping(value = "/dustfreeAndmajorlist")
    @ResponseBody
    public String dustfreeAndmajorlist(HttpServletRequest request) {
    	List<Code> list = codeService.dustfreeAndmajorlist(); 
    	Map<String, Object> returnMap = new HashMap<String, Object>(); 
    	if(list.size()>0){
        	returnMap.put("err_code", "0");
            returnMap.put("err_msg", "success");
            returnMap.put("result", list);
    	}
//    	String s = JsonUtil.toJson(returnMap);
    	return JsonUtil.toJson(returnMap);
    	
    }
    
}
